from django.db import models

# Create your models here.
class Department(models.Model):
    """部门表"""
    id = models.AutoField(verbose_name='部门ID', primary_key=True)
    title = models.CharField(verbose_name='部门名称', max_length=32)
    def __str__(self):
        return self.title


class UserInfo(models.Model):
    """用户信息表"""
    id = models.AutoField(verbose_name='用户ID', primary_key=True)
    name = models.CharField(verbose_name='用户名', max_length=32)
    password = models.CharField(verbose_name='密码', max_length=32)
    age = models.IntegerField(verbose_name='年龄', default=0)
    account = models.CharField(verbose_name='余额',default=0, max_length=32)
    create_time = models.DateField(verbose_name='入职时间')
    depart = models.ForeignKey(to="Department",to_field='id', verbose_name='部门', null=True, blank=True, on_delete=models.CASCADE)
    sex = models.CharField(verbose_name='性别', max_length=10, choices=(('男', '男'), ('女', '女')))




class PrettyNum(models.Model):
    """电话号码表"""
    id = models.AutoField(verbose_name='电话ID', primary_key=True)
    mobile = models.CharField(verbose_name='电话', max_length=11)
    price = models.IntegerField(verbose_name='价格', default=0)
    level_choices = (
        ('1', '1级'),
        ('2', '2级'),
        ('3', '3级'),
    )
    level = models.CharField(verbose_name='级别', max_length=10, choices=level_choices,default='A')
    status_choices = (
        ('1', '正常'),
        ('2', '停机'),
    )
    status = models.CharField(verbose_name='状态', max_length=10, choices=status_choices,default='1')




class Admin(models.Model):
    """管理员表"""
    id = models.AutoField(verbose_name='管理员ID', primary_key=True)
    username = models.CharField(verbose_name='管理员名称', max_length=32)
    password = models.CharField(verbose_name='密码', max_length=32)
    def __str__(self):
        return self.username






class Task(models.Model):
    """任务"""

    level_choices = (
        (1, "紧急"),
        (2, "重要"),
        (3, "临时"),
    )
    level = models.SmallIntegerField(verbose_name="级别", choices=level_choices, default=1)
    title = models.CharField(verbose_name="标题", max_length=64)
    detail = models.TextField(verbose_name="详细信息")
    user = models.ForeignKey(verbose_name="负责人", to=Admin, on_delete=models.CASCADE)


class Order(models.Model):
    """ 订单 """
    oid = models.CharField(verbose_name="订单号", max_length=64)
    title = models.CharField(verbose_name="名称", max_length=32)
    price = models.IntegerField(verbose_name="价格")

    status_choices = (
        (1, "待支付"),
        (2, "已支付"),
    )

    status = models.SmallIntegerField(verbose_name="状态", choices=status_choices, default=1)
    admin = models.ForeignKey(Admin, verbose_name="管理员", on_delete=models.CASCADE)


class Order(models.Model):
    """ 订单 """
    oid = models.CharField(verbose_name="订单号", max_length=64)
    title = models.CharField(verbose_name="名称", max_length=32)
    price = models.IntegerField(verbose_name="价格")

    status_choices = (
        (1, "待支付"),
        (2, "已支付"),
    )

    status = models.SmallIntegerField(verbose_name="状态", choices=status_choices, default=1)
    admin = models.ForeignKey(Admin, verbose_name="管理员", on_delete=models.CASCADE)

